import time
# {
#     "code": 20000,
#     "message": "success",
#     "length": 48,
#     "data": {
#         "data": [
#             {
#                 "id": 51,
#                 "username": "zhangxuemin",
#                 "realname": null,
#                 "nickname": "zhangxuemin",
#                 "mobile": null,
#                 "wechat": null,
#                 "corpid": 29,
#                 "depid": null,
#                 "password": "7a46f1d7578503f9dc6883948fad4d77",
#                 "role": "normal",
#                 "cname": "remote system",
#                 "ctime": "2023-09-01",
#                 "ltime": "2023-09-01",
#                 "icon": "default",
#                 "status": 1
#             }
#         ]
#     }
# }
# 返回处理成功的信息
def success(adata, tlen = 0, msg="处理成功"):

    tm = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
    result = {}
    result["code"] = 20000
    result["message"] = "sucess"
    if tlen == 0:
        result["length"] = len(adata)
    else:
        result["length"] = tlen
    result["time"] = tm
    ddata = {}
    ddata["data"] = adata
    result["data"] = ddata
    return result

def success1(adata, msg="处理成功"):

    tm = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
    result = {}
    result["code"] = 20001
    result["message"] = msg
    result["length"] = 0
    result["time"] = tm
    ddata = {}
    ddata["data"] = adata
    result["data"] = ddata
    return result

#返回处理失败的信息
def error(rjson = None, flag=-1, msg="处理失败"):
    
    tm = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
    result = {}
    result["code"] = 90000
    result["message"] = msg
    result["length"] = 0
    result["time"] = tm
    result["data"] = None
    return result